home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 081 / editstat.arc / ES.C next >
Encoding:
C/C++ Source or Header  |  1986-10-05  |  3.3 KB  |  107 lines

  1.  
  2. #include "include\stdio.h"
  3. #include "include\stdlib.h"
  4. #include "include\string.h"
  5. #define S1 " "
  6.  
  7.  extern struct  usr {
  8.      char name[36];      /* users ASCII name, */
  9.      char city[36];      /* city and state, */
  10.      struct {
  11.              int area;   /* message area */
  12.              int msg;    /* last msg read */
  13.      } lastmsg[10];
  14.      char pwd[16];       /* what else, */
  15.      int times;          /* # times called, */
  16.      int help;           /* last help setting, */
  17.      int tabs;           /* 1 == expand tabs, */
  18.      int nulls;          /* number of nulls */
  19.      int lmsgarea;       /* last message area, */
  20.      int more;           /* last MORE setting, */
  21.      int priv;           /* user privilege level, */
  22.      char ldate[20];     /* last time called, */
  23.      int time;           /* time on sys in 1 day */
  24.      unsigned flag;      /* various bit flags, */
  25.      unsigned upld;      /* total K byte uploaded, */
  26.      unsigned dnld;      /* total K bytes downldd, */
  27.      unsigned dnldl;     /* download limiting, */
  28.      int files;          /* last file area, */
  29.      char width;         /* screen width, */
  30.      char len;           /* screen length, */
  31.      int credit;         /* credit, in cents, */
  32.      int debit;          /* debit, in cents, */
  33.      } 
  34.  
  35. go(argc,argv)
  36.   int argc;
  37.   char *argv[];
  38. {
  39.  
  40.  
  41.  int rec_no,i=0,triage=1;
  42.  FILE *fp;
  43.  static struct usr record;
  44.  char *buffer;
  45.  char source[20];
  46.  unsigned *new_upld,*new_dnld;
  47.   cls();
  48.  if(argc<2) {
  49.       printf("\n\nYou need the Firstname Lastname exactly as it appears in the userlist");
  50.       printf("\nand you need the first letters of each Capitalized as shown.\n\n");
  51.       exit(1);
  52.       }
  53.  
  54.  if( (fp = fopen("user.bbs","r+b"))==0){
  55.       printf("USER.BBS is NOT in the CURRENT directory. Please correct.\n");
  56.       exit(1);
  57.       }
  58.  
  59.   if( fseek(fp,0l,0)==0) {
  60.      buffer = &record;
  61.      if(argc > 2) {
  62.      strcpy(source,argv[1]);
  63.      strcat(source,S1);
  64.      strcat(source,argv[2]);
  65.      }
  66.     else strcpy(source,argv[1]);
  67.      while( (strcmp(source,record.name) != 0)) {
  68.  
  69.      if(fread(buffer,180,1,fp)<1) {
  70.          printf("\n\nSorry, but I cannot seem to find %s.",source);
  71.          exit(1);
  72.      }
  73.  
  74.          i++;
  75.          }
  76.     }
  77.          else {
  78.               printf("Seek error in USER.BBS and Rec-no is %d",i);
  79.               exit(1);
  80.               }
  81.  printf("\nFound %s and the record number is %u.\n",source,i);
  82.  new_upld = record.upld;
  83.  new_dnld = record.dnld;
  84.  while(triage>0 && triage<3) {
  85.      printf("   %s uploaded %u Kbytes and downloaded %u Kbytes.\n",source,new_upld,new_dnld);
  86.      printf("\n\n     0==>Exit   1==>Change Upload Stats   2==>Change Download Stats ==>");
  87.      scanf("%d",&triage);
  88.      if(triage == 1) {
  89.          printf("\n Change uploads from %u Kbytes to ==>",new_upld);
  90.          scanf("%u",&new_upld);
  91.          continue;
  92.          }
  93.     if(triage == 2)  {
  94.          printf("\n Change downloads from %u Kbytes to ==>",new_dnld);
  95.          scanf("%u",&new_dnld);
  96.          continue;
  97.          }
  98.    }
  99.  if((new_dnld != record.dnld) || (new_upld != record.upld))  {
  100.      record.dnld = new_dnld;
  101.      record.upld = new_upld;
  102.      fseek(fp,ftell(fp)-180,0);
  103.      fwrite(buffer,180,1,fp);
  104.      }
  105.  fclose(fp);
  106.  }
  107.